module.exports = {
    /**
     * 添加城市--后台管理
     * @url user/kh/postOrderConfig 前端调用的url参数地址
     */
    main: async (event) => {
          let { data = {}, userInfo, util, originalParam } = event;
          let { uniID, pubFun, vk , db, _ } = util;
          let res = { code : 0, msg : 'ok' };
      
          // 业务逻辑开始----------------------------------------------------------- 
          let dbName = "vk-house"
          let obj = { ...data}
          // return {
          //     code: 0,
          //     msg: userInfo
          // }
          if (userInfo.role.indexOf('fang-admin') || userInfo.role.indexOf('fang-worker') ) {
            let info = await db.collection(dbName).count();
            console.log(info, 'info------')
            // 编号
            obj.no = 'xiaoxi' + info.total++
            // 状态 1 上架 2审核 3 下架 4 删除
            if (userInfo.role.indexOf('fang-admin')) {
                obj.status = 1
            }
            if (userInfo.role.indexOf('fang-woker')) {
                obj.status = 2
            }
          } else {
            return {
                code: 412,
                msg: '无权限操作'
            }
          }
          
          res.data = await vk.baseDao.add({
              dbName,
              dataJson: obj
          },event.util);
          return res;
    }
  
  }